PROCESSES=`jps`

EXISTAPROCESS=0
EXISTEPROCESS=0
HASAKEY=0
HASEKEY=0

for p in $PROCESSES; do
    if [ $p = "spider-schedule-0.0.1.jar" ] ; then
        EXISTAPROCESS=1
    fi
    if [ $EXISTAPROCESS = 1 ] ; then
        HASAKEY=1
    fi

    if [ $p = "spider-data-extract-0.0.1-SNAPSHOT.jar" ] ; then
        EXISTEPROCESS=1
    fi
    if [ $EXISTEPROCESS = 1 ] ; then
        HASEKEY=1
    fi
done

if [ $HASAKEY = 1 ] ; then
    echo "Send SIGQUIT APP ..."
    kill -9 `cat app.pid`
    rm app.pid
fi

if [ $HASEKEY = 1 ] ; then
    echo "Send SIGQUIT Extractor ..."
    kill -9 `cat extract.pid`
    rm extract.pid
fi


